package com.zengqingfa.springboot.validation.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;


@RestController
@RequestMapping("/user")
@Slf4j
@Validated
public class UserRest2 {


    /**
     * 用户详情
     *
     * @param userId
     * @return
     */
    @GetMapping("/{userId}")
    public String detail(@PathVariable("userId") @Min(10000L) Long userId) {
        // 校验通过，才会执行业务逻辑处理
        log.info("userId:{}", userId);
        return userId.toString();
    }

}
